from django.shortcuts import redirect


def login_wrapper(f):  # 装饰器函数，f是被装饰的函数
    def inner(request, *args, **kwargs):  #
        username = request.session.get("username", None)
        if not username:
            return redirect("/index.html")

        '''在被装饰函数之后要做的事'''

        return f(request, *args, **kwargs)  # 被装饰的函数

    return inner
